//
//从mp4中抽取视频h264
// Created by lianglei on 2019/10/31.
//

#ifndef KALIVIDEOMAKER_EXTRVIDEOMODULE_H
#define KALIVIDEOMAKER_EXTRVIDEOMODULE_H

#endif //KALIVIDEOMAKER_EXTRVIDEOMODULE_H

extern "C" {
#include <libavformat/avformat.h>
#include <libavcodec/avcodec.h>
}

#include "log/androilog.h"
#include <jni.h>
#include <string>
#include "MediaInfomation.h"

#ifndef AV_RB16
#   define AV_RB16(x)                           \
    ((((const uint8_t*)(x))[0] << 8) |          \
      ((const uint8_t*)(x))[1])
#endif

#ifndef AV_WB32
#   define AV_WB32(p, val) do {                 \
        uint32_t d = (val);                     \
        ((uint8_t*)(p))[3] = (d);               \
        ((uint8_t*)(p))[2] = (d)>>8;            \
        ((uint8_t*)(p))[1] = (d)>>16;           \
        ((uint8_t*)(p))[0] = (d)>>24;           \
    } while(0)
#endif

class ExtrVideoModule {

public:
    int err_code;
    char errors[1024];
    const char *src_filename = NULL;
    const char *dst_filename = NULL;
    FILE *dst_fd = NULL;
    AVFormatContext *fmt_ctx = NULL;
    AVPacket pkt;
    MediaInfoPacket mediaInfoPacket;

public:
    void _extrVideo(const char *_path, const char *_targPath);


};
